//
//  comment.m
//  Four_Fit
//
//  Created by lanou on 16/7/13.
//  Copyright © 2016年 xmaz. All rights reserved.
//

#import "comment.h"

@implementation comment

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
    if ([key isEqualToString:@"items"]) {
        self.commentContent = value[@"content"];
    }
}

- (NSInteger)headerHeight {
    
    
    // 文字的最大尺寸
    CGSize maxSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - 30, MAXFLOAT);
    
    //计算标题文字所需要的高度
    CGFloat titleTextH = [_title boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:22]} context:nil].size.height;
    
    //计算文字所需要的高度
    CGFloat textH = [_content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil].size.height;
    
    if (_pic.count == 1) {
        
        _pictureViewFrame = CGRectMake(20, 70 + titleTextH + textH + 20, kWidth - 40, kWidth - 30);
        
        _headerHeight = 70 + titleTextH + textH + 20 + kWidth - 20;
    } else if (_pic.count == 2) {
        
        _pictureViewFrame = CGRectMake(20, 70 + titleTextH + textH + 20, kWidth - 40, 180);
        
        _headerHeight = 70 + titleTextH + textH + 20 + 180 + 10;
        
    } else if (_pic.count == 3) {
        
        _pictureViewFrame = CGRectMake(20, 70 + titleTextH + textH + 20, kWidth - 40, kWidth - 100);
        
        _headerHeight = 70 + titleTextH + textH + 20 + kWidth - 100 + 10;
        
    } else if (_pic.count == 0) {
        
        _headerHeight = 70 + titleTextH + textH + 20 + 10;
    }
    
    return _headerHeight;
}

@end
